package fun.boomcat.luckyhe.mirai.plugin.botcontrol.util;

import net.mamoe.mirai.console.command.CommandSender;
import net.mamoe.mirai.contact.Group;
import net.mamoe.mirai.contact.GroupSettings;

/**
 * @author Lucky_He
 * @date 2021年8月20日 0:48
 * @description 群设置相关
 */
public class GroupSettingOperation {
    public static void groupSettingOperation(CommandSender commandSender, Object[] args, GroupSettings settings, Group group) {
        String lineNum = args[0].toString();

        int num;
        try {
            num = Integer.parseInt(lineNum);
        } catch (Exception e) {
            commandSender.sendMessage("错误：" + e.toString());
            return;
        }

        boolean old;
        switch (num) {
            case 1:
                old = settings.isMuteAll();
                settings.setMuteAll(!old);
                commandSender.sendMessage("已将群" + group.getId() + "的全体禁言从" + old + "改变为" + !old);
                break;

            case 2:
                old = settings.isAllowMemberInvite();
                settings.setAllowMemberInvite(!old);
                commandSender.sendMessage("已将群" + group.getId() + "的允许邀请好友从" + old + "改变为" + !old);
                break;

            default:

                commandSender.sendMessage("没有编号为" + num + "的设置项");
                break;
        }
    }
}
